package pay

import (
	"context"
	"git.900sui.cn/kc/rpcPay/common/models"
	"git.900sui.cn/kc/rpcinterface/interface/bus"
	"git.900sui.cn/kc/rpcinterface/interface/order"
	pay2 "git.900sui.cn/kc/rpcinterface/interface/pay"
	"github.com/shopspring/decimal"
	"github.com/tidwall/gjson"
)

/**
 * @className pingan
 * @author liyang<654516092@qq.com>
 * @date 2021/4/8 15:56
 */

type pingpp struct {
}

//生成二维码
func (p *pingpp) PayQr(payInfo *pay2.PayInfo) (string, error) {
	return "", nil
}

//h5支付-收银台
func (p *pingpp) PayH5(payInfo *pay2.PayInfo) (string, error) {
	return "", nil
}

//h5 升级版本
func (p *pingpp) PayH5New(payInfo *pay2.PayInfo, ps *pay2.PayH5) (err error) {
	return nil
}

//微信小程序付款
func (p *pingpp) PayWxApp(payInfo *pay2.PayInfo) (*gjson.Result, error) {
	return nil, nil
}

// 微信公众号支付
func (p *pingpp) PayWxOfficial(payInfo *pay2.PayInfo) (*gjson.Result, error) {
	return nil, nil
}

// APP支付【微信/支付宝】-直连
func (p *pingpp) PayApp(payInfo *pay2.PayInfo) (*gjson.Result, error) {
	return nil, nil
}

//获取支付签名字符串
func (p *pingpp) PayAppSign(payInfo *pay2.PayInfo) (string, error) {
	return "", nil
}

//异步回调通知 raw json
func (p *pingpp) Notify(data string) (*pay2.PayNotify, error) {
	return nil, nil
}

//异步回调响应
func (p *pingpp) NotifyResponse(ctx context.Context, args *pay2.ArgsNotify) (*pay2.ReplyNotifyResponse, error) {
	return nil, nil
}

// 获取支付成功后金额处理
func (s *pingpp) PayFund(notify *pay2.PayNotify, bill *order.ReplyGetOrderSplitBill) []bus.FundRecordItem {
	return []bus.FundRecordItem{
		{
			OrderSn:  notify.OrderSn,
			Amount:   notify.PayAmount,
			FundType: bus.FUND_TYPE_pay_in,
		}, {
			OrderSn:  notify.OrderSn,
			Amount:   notify.PayFee,
			FundType: bus.FUND_TYPE_bankfee_out,
		}, {
			OrderSn:  notify.OrderSn,
			Amount:   decimal.NewFromFloat(bill.InsureAmount).String(),
			FundType: bus.FUND_TYPE_insurance_out,
		}, {
			OrderSn:  notify.OrderSn,
			Amount:   decimal.NewFromFloat(bill.RenewInsureAmount).String(),
			FundType: bus.FUND_TYPE_reinsurance_out,
		}, {
			OrderSn:  notify.OrderSn,
			Amount:   decimal.NewFromFloat(bill.PlatformAmount).String(),
			FundType: bus.FUND_TYPE_plat_out,
		}, {
			OrderSn:  notify.OrderSn,
			Amount:   decimal.NewFromFloat(bill.DepositAmount).String(),
			FundType: bus.FUND_TYPE_depository,
		}, {
			OrderSn:  notify.OrderSn,
			Amount:   decimal.NewFromFloat(bill.BusAmount).Sub(decimal.NewFromFloat(bill.DepositAmount)).String(),
			FundType: bus.FUND_TYPE_usable,
		},
	}
}

// 获取清分金额
func (p *pingpp) GetFundAmount(notify *pay2.PayNotify, bill *order.ReplyGetOrderSplitBill) string {
	return ""
}

//获取支付方式
func (p *pingpp) GetType() int {
	return order.PAY_CHANNEL_pingpp
}
func (p *pingpp) AgentChannel(busClearingModel *models.BusClearingModel, list map[string]interface{}) (id int, err error) {
	return
}
func (p *pingpp) FundAgent(ctx context.Context) (rest bool) {
	return
}
func (p *pingpp) FundAgentResult(ctx context.Context) (rest bool) {
	return
}

func (p *pingpp) GetInsureFund() bool {
	return false
}

func (p *pingpp) AgentChannelInsure(insureClearingModel *models.InsureClearingModel, list map[string]interface{}) (id int, err error) {
	return
}

func (p *pingpp) AgentChannelPlat(platClearingModel *models.PlatformClearingModel, list map[string]interface{}) (id int, err error) {
	return
}

func (p *pingpp) AgentChannelRenewInsure(renewInsureClearingModel *models.RenewInsureClearingModel, list map[string]interface{}) (id int, err error) {
	return
}
